import { getDatePickerCellValue } from "./ElDatePicker";
import { createExportMethod, createProps } from "./common";
import { h } from "vue";
import XEUtils from "xe-utils";
import EditorPopupModalTable from "../../../EditorPopupModal/tableEdit.vue";
export default {
    renderEdit(renderOpts: any, params: any) {
        const { row, column } = params;
        const { attrs } = renderOpts;
        const cellValue = XEUtils.get(row, column.field as string);
        return [
            h(EditorPopupModalTable, {
                ...attrs,
                ...createProps(renderOpts, cellValue, {}),
                renderOpts,
                params,
                row,
                column,
                ...renderOpts.attrs,
                modelValue: row[column.property],
                "onUpdate:modelValue"(value: any) {
                    XEUtils.set(row, column.property as string, value);
                },
            }),
        ];
    },
    exportMethod: createExportMethod(getDatePickerCellValue),
    // 表单项内容模板
    renderItemContent(renderOpts: any, params: any) {
        const { data, property } = params;
        const { props } = renderOpts;
        return [
            h(EditorPopupModalTable, {
                ...props,
                ...createProps(renderOpts, params, {}),
                renderOpts,
                params,
                ...renderOpts.attrs,
                modelValue: data[property],
                "onUpdate:modelValue"(value: any) {
                    XEUtils.set(data, property as string, value);
                },
            }),
        ];
    },
};
